#ifndef DICTIONARY_TYPES_H
#define DICTIONARY_TYPES_H

#include <string>
#include <algorithm>
#include "Grammar.h"
namespace Dictionary
{
  enum SectionType { text=0,link=1,title=2,meta_keyword=3,meta_description=4,heading = 5,caption =6 , none = 100};

	SectionType get_section_type_by_string(const std::string & section_string) {
		if (Grammar::TEXTTYPE() == section_string) return text;
		else if (Grammar::LINKTYPE() == section_string) return link;
		else if (Grammar::TITLETYPE() == section_string) return title;
		else if (Grammar::METAKEYWORDTYPE() == section_string) return meta_keyword;
		else if (Grammar::METADESCRIPTIONTYPE() == section_string) return meta_description;
		else if (Grammar::HEADINGTYPE() == section_string) return heading;
		else if (Grammar::CAPTIONTYPE() == section_string) return caption;
		else return none;
	}

	template <typename T>
	struct DeleteContainerContent : std::unary_function<T*,void> {
				void operator()(T* sen) {
					if (sen != NULL) {
						delete sen;
						sen = NULL;
					}
				}
	};

	template <typename T>
	struct DeleteMapContainerContent : std::unary_function<T,void> {
		void operator() (T &item) {
			if (item.second != NULL) {
				delete item.second;
				item.second = NULL;
			}
		}
	};

	template <typename T1, typename T2>
	struct DeleteMapMapContainerContent : std::unary_function<T1,void> {
		void operator() (T1 &item) {
			if (item.second != NULL) {
				std::for_each(item.second->begin(),item.second->end(),DeleteMapContainerContent<T2>());
				delete item.second;
				item.second = NULL;
			}
		}
	};

}

#endif